<html>
	<body>
	
	<form  action="community_add.php" method = "GET">

		<div>Community Name <input type = "text"  name = "community_name"></div>
			<div>longitude <input type = "text"  name = "longitude"></div>
				<div>latitude <input type = "text"  name = "latitude"></div>
				<!--<div>Community_id <input type = "text"  name = "community_id"></div>-->
				<div>population <input type = "text"  name = "population"></div>
				<div>household <input type = "text"  name = "household"></div>
				<!--<div>Subdistrict ID <input type = "text"  name = "subdistrict_id"></div>-->
				Subdistrict <select name="subdistrict_id">
				<option value = "0" > All	</option>
				<option value = "1" > Aburi </option>
				<option value = "2"> Pokrum </option>
	
	</select>
	<input type = "submit" name = "submit" value ="Add">
	</form>
<?php

	function add(){
		//alert up to say are you sure you want to save
		//yes -> save in databae
		//no -> redirect to  homepage
		//use onclick for this
	}

	$community_id = null;
	//if(isset($_REQUEST["community_id"])){
	//$community_id = $_REQUEST["community_id"];
	//}
		
	$latitude = 0;
	if(isset($_REQUEST["latitude"])){
	$latitude = $_REQUEST["latitude"];
	}
			$longitude = 0;
	if(isset($_REQUEST["longitude"])){
	$longitude = $_REQUEST["longitude"];
	}
	
	
	$population = 0;
	if(isset($_REQUEST["population"])){
	$population = $_REQUEST["population"];
	}
	
	$household = 0;
	if(isset($_REQUEST["household"])){
	$household= $_REQUEST["household"];
	}
	
		$community_name = "";
	if(isset($_REQUEST["community_name"])){
	$community_name = $_REQUEST["community_name"];
	}
	
/*	$subdistrict_id = 0;
	if(isset($_REQUEST["subdistrict_id"])){
	$subdistrict_id = $_REQUEST["subdistrict_id"];
	} */
	
	$subdistrict_id = 0;
	if(isset($_REQUEST["subdistrict_id"])){
	$subdistrict_id = $_REQUEST["subdistrict_id"];
	}
	
	if($subdistrict_id == 0){
	$query = mysql_query("select*from community");
	}else{
	$query =mysql_query("select * from community where subdistrict_id = $subdistrict_id");
	}
	
	
		include("community.php");
	$obj = new community();
	if(!$obj -> add_community($community_id,  $latitude, $longitude,
				$population, $household, $community_name, $subdistrict_id)){
		echo"error";
		echo mysql_error($obj->link);
		exit();
	}
	
	//$row = $obj -> fetch();
	//print_r($row);
	//mysql_query($row,$link);
	
	
	

	
	
	
?>
	
		</table>
	</body>
</html>	
	